import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { NestExpressApplication } from '@nestjs/platform-express';
import { ValidationPipe } from '@nestjs/common';
import { HttpExceptionFilter } from './core/filter/http-exception/http-exception.filter';
import { TransformInterceptor } from './core/interceptor/transform/transform.interceptor';
async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  app.enableCors();
  app.setGlobalPrefix('api');
  app.useStaticAssets('states', {
    prefix: '/states',
  });
  app.useGlobalFilters(new HttpExceptionFilter()); //错误拦截器
  app.useGlobalInterceptors(new TransformInterceptor()); // 成功拦截器
  app.useGlobalPipes(new ValidationPipe()); //验证器处理错误数据验证。验证器应将错误数据转换为数
  await app.listen(9080);
}
bootstrap();
